home *** CD-ROM | disk | FTP | other *** search
- class FPUI.SelectableItem extends FPUI.Component
- {
- var m_labelFieldMC;
- var m_itemNum;
- var m_controller;
- var controller;
- var onPress;
- var m_boldLF = false;
- var m_highlightMC = null;
- var m_lastDrawnColor = FPUI.Component.kWhiteBgColor;
- function SelectableItem()
- {
- var _loc1_ = this;
- super();
- _loc1_.createTextField("m_labelFieldMC",1,0,0,1,1);
- _loc1_.m_labelFieldMC.embedFonts = false;
- _loc1_.m_labelFieldMC.selectable = false;
- _loc1_.m_labelFieldMC.autosize = true;
- }
- function calcLabelHeight(s)
- {
- this.setLabel(s);
- return this.m_labelFieldMC._height;
- }
- function setLabel(label)
- {
- var _loc1_ = this;
- if(_loc1_.m_labelFieldMC.text != label)
- {
- _loc1_.m_labelFieldMC.text = label;
- _loc1_.updateLabelStyle();
- }
- }
- function drawItem(itmObj, selected, index)
- {
- this.displayContent(itmObj,selected,index);
- }
- function getHighlightHeight()
- {
- return this.m_highlightMC._height;
- }
- function doClickHandler()
- {
- this.m_controller.clickHandler(this.m_itemNum);
- }
- function fillHighlight(ca)
- {
- var _loc1_ = this;
- _loc1_.m_highlightMC.clear();
- FPUI.Component.fillRect(_loc1_.m_highlightMC,0,0,_loc1_.m_width,_loc1_.m_height,ca);
- }
- function assignHighlightFunctions(b)
- {
- var _loc2_ = this;
- var _loc1_ = _loc2_.m_highlightMC;
- if(b)
- {
- _loc1_.onPress = function()
- {
- var _loc1_ = this.controller;
- if(_loc1_.getEnabled())
- {
- _loc1_.doClickHandler();
- }
- };
- _loc1_.onDragOver = function()
- {
- var _loc1_ = this.controller;
- if(_loc1_.m_controller.getFocused())
- {
- this.onPress();
- }
- };
- _loc1_.onRollOver = function()
- {
- var _loc1_ = this.controller;
- if(_loc1_.m_controller.hasCursorFocus())
- {
- _loc1_.fillHighlight(FPUI.Component.kRolloverColor);
- }
- };
- _loc1_.onRollOut = function()
- {
- var _loc1_ = this.controller;
- _loc1_.fillHighlight(_loc1_.m_lastDrawnColor);
- };
- }
- else
- {
- _loc1_.onPress = _loc1_.onDragOver = _loc1_.onRollOver = _loc1_.onRollOut = null;
- }
- }
- function setSize(width, height)
- {
- var _loc1_ = this;
- var _loc3_ = width;
- var _loc2_ = -16384;
- _loc1_.m_width = _loc3_;
- _loc1_.m_height = height;
- _loc1_.m_labelFieldMC._x = 2;
- _loc1_.m_labelFieldMC._y = 0;
- _loc1_.m_labelFieldMC._width = _loc3_ - 2;
- if(_loc1_.m_highlightMC == undefined)
- {
- _loc1_.createEmptyMovieClip("m_highlightMC",_loc2_);
- _loc1_.fillHighlight(FPUI.Component.kWhiteBgColor);
- _loc1_.m_highlightMC._x = _loc1_.m_highlightMC._y = 0;
- _loc1_.m_highlightMC.controller = _loc1_;
- _loc1_.m_highlightMC.trackAsMenu = true;
- _loc1_.m_highlightMC.useHandCursor = false;
- }
- _loc1_.m_highlightMC._width = _loc3_;
- _loc1_.m_highlightMC._height = height;
- }
- function setEnabled(enabledFlag)
- {
- var _loc1_ = this;
- if(_loc1_.m_enable != enabledFlag)
- {
- _loc1_.m_enable = enabledFlag;
- _loc1_.updateLabelStyle();
- }
- }
- function setMinHighlightWidth(width)
- {
- this.m_highlightMC._width = Math.max(this.m_width,width);
- }
- function updateLabelStyle()
- {
- var _loc1_ = this;
- if(_loc1_.m_labelFieldMC)
- {
- _loc1_.m_labelFieldMC.setTextFormat(new TextFormat(FlashPaper.Utils.UIFONT,FlashPaper.Utils.UIFONTSIZE,!_loc1_.m_enable ? 8947848 : 0,_loc1_.m_boldLF));
- _loc1_.m_labelFieldMC._height = _loc1_.m_labelFieldMC.textHeight + 2;
- }
- }
- function setLabelBold(bold)
- {
- var _loc1_ = this;
- if(_loc1_.m_boldLF != bold)
- {
- _loc1_.m_boldLF = bold;
- _loc1_.updateLabelStyle();
- }
- }
- function displayContent(itmObj, selected, index)
- {
- var _loc1_ = this;
- var _loc2_ = _loc1_.m_lastDrawnColor;
- if(itmObj)
- {
- _loc1_.setLabel(itmObj.getDataItemLabel() + " ");
- if(selected && _loc1_.m_controller.getFocused())
- {
- _loc2_ = FPUI.Component.kHiliteColor;
- }
- else
- {
- _loc2_ = FPUI.Component.kWhiteBgColor;
- }
- _loc1_.assignHighlightFunctions(true);
- }
- else
- {
- _loc1_.setLabel("");
- _loc2_ = FPUI.Component.kWhiteBgColor;
- _loc1_.assignHighlightFunctions(false);
- }
- if(_loc1_.m_lastDrawnColor != _loc2_)
- {
- _loc1_.m_lastDrawnColor = _loc2_;
- _loc1_.fillHighlight(_loc1_.m_lastDrawnColor);
- }
- }
- }
-